package com.jch.lx;

import org.apache.flink.api.common.RuntimeExecutionMode;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Arrays;

public class Test {

    public static void main(String[] args) throws Exception{

       //流处理
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        env.setRuntimeMode(RuntimeExecutionMode.AUTOMATIC);

        //1.env.fromElements(可变参数)
        DataStreamSource<String> ds1 = env.fromElements("hadoop", "spark", "flink");

        //2.env.fromCollection(各种集合)
        DataStreamSource<Object> ds2 = env.fromCollection(Arrays.asList("hadoop",
                "spark","flink"));

        //3.env.generateSequence(开始 结束)
        DataStreamSource<Long> ds3 = env.generateSequence(1, 10);

        //4.fromSequence(开始，结束)
        DataStreamSource<Long> ds4 = env.fromSequence(1, 5);

        ds1.print();
        ds2.print();
        ds3.print();
        ds4.print();

        env.execute();

    }


}
